from django.db import models
from django.utils.timezone import now

# Create your models here.
class Genres(models.Model):
    category=models.CharField(max_length=70)
    def __str__(self):
        return self.category

class RPT_Category(models.Model):
    rpt_category=models.CharField(max_length=70)

    def __str__(self):
        return self.rpt_category
class LRT_Catgory(models.Model):
    LRT_category = models.CharField(max_length=70)

    def __str__(self):
        return self.LRT_category


class Pay_more_attention(models.Model):
    degree = models.CharField(max_length=2,default=1)
    def __str__(self):
        return self.degree

class HotTopic(models.Model):
    ishottopic=models.BooleanField(default=False,verbose_name='是否是HotTopic系列的影片')
    def __str__(self):
        if self.ishottopic:
            return 'True'
        else:
            return 'False'

class MovieInfo(models.Model):
    """
    设置电影各类信息的存储
    """
    movie_class=models.CharField(max_length=20,default='new')#电影分类，是new，classical，还是其他
    movie_name=models.CharField(max_length=70) #电影名
    movie_content=models.CharField(max_length=300)#电影内容，主题
    release_time=models.DateField(default=now)#发布时间
    movie_image=models.ImageField(upload_to='movie')#图片存储
    movie_category=models.ManyToManyField(Genres)#电影分类
    movie_rtpcatgory=models.ManyToManyField(RPT_Category)
    movie_lrtcatgory = models.ManyToManyField(LRT_Catgory)
    movie_degree=models.ForeignKey('Pay_more_attention',on_delete=models.CASCADE,default=None,blank=True)#此类分类为展示图片设计
    movie_hottopic=models.ForeignKey('HotTopic',on_delete=models.CASCADE,default=False,blank=True)#是否热门，详情页面显示

    def __str__(self):
        return self.movie_name


class Movie_recent_visit(models.Model):
    movie_id=models.ForeignKey('MovieInfo',on_delete=models.CASCADE,max_length=5,verbose_name='记录访问过电影的id')
    visit_time=models.DateField(default=now,verbose_name='记录访问时间')
    #记录访问时间，为最近浏览所用









